package com.yiyi.user.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yiyi.common.annotation.Log;
import com.yiyi.common.core.controller.BaseController;
import com.yiyi.common.core.domain.AjaxResult;
import com.yiyi.common.enums.BusinessType;
import com.yiyi.user.domain.SysWxcode;
import com.yiyi.user.service.ISysWxcodeService;
import com.yiyi.common.utils.poi.ExcelUtil;
import com.yiyi.common.core.page.TableDataInfo;

/**
 * 企业微信二维码Controller
 *
 * @author yiyi
 * @date 2024-09-26
 */
@RestController
@RequestMapping("/wxcode/wxcode")
public class SysWxcodeController extends BaseController
{
    @Autowired
    private ISysWxcodeService sysWxcodeService;

    /**
     * 查询企业微信二维码列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SysWxcode sysWxcode)
    {
        startPage();
        List<SysWxcode> list = sysWxcodeService.selectSysWxcodeList(sysWxcode);
        return getDataTable(list);
    }

    /**
     * 导出企业微信二维码列表
     */
    @Log(title = "企业微信二维码", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysWxcode sysWxcode)
    {
        List<SysWxcode> list = sysWxcodeService.selectSysWxcodeList(sysWxcode);
        ExcelUtil<SysWxcode> util = new ExcelUtil<SysWxcode>(SysWxcode.class);
        util.exportExcel(response, list, "企业微信二维码数据");
    }

    /**
     * 获取企业微信二维码详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysWxcodeService.selectSysWxcodeById(id));
    }

    /**
     * 新增企业微信二维码
     */
    @Log(title = "企业微信二维码", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysWxcode sysWxcode)
    {
        return toAjax(sysWxcodeService.insertSysWxcode(sysWxcode));
    }

    /**
     * 修改企业微信二维码
     */
    @Log(title = "企业微信二维码", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysWxcode sysWxcode)
    {
        return toAjax(sysWxcodeService.updateSysWxcode(sysWxcode));
    }

    /**
     * 删除企业微信二维码
     */
    @Log(title = "企业微信二维码", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysWxcodeService.deleteSysWxcodeByIds(ids));
    }
}
